<?php
require_once "db.php";
$typeAction = db_escape($_POST['typeAction']);
if($typeAction == "1"){
	$addCinemaForm = "<div id=add_cin_form> <form id='add-cinema' method='post' action='addCinema.php'>
				<label class='acinema' for='cinema_name'>Cinema name: </label>
				<input type='text' id='cinema_name' name='cinema_name'/>
				<br/>
				<label class='acinema' for='address'>Address: </label>
				<input type='text' id='address' name='address'/>
				<br/>
				<label class='acinema' for='logo'>Enter logo path: </label>
				<input type='text' id='logo' name='logo'/>
				<br/>
				<input type='submit' name='addCinema' value='AddCinema'/>
			</form></div>";
	echo $addCinemaForm;
}

if($typeAction == "2"){
	$rvCinemaForm = "<div id='rv_cin_form'>
	<form id='rv-cinema' method='post' action='rvCinema.php'>
	<label for='rem_cin'>Choose which cinema to remove</label><select id='rem_cinema' name='rem_cin'>";
	$query = "SELECT cinema_name FROM cinema WHERE active_or_not = 0";
	$get_cinema = db_query($query);
	while ($row = mysqli_fetch_assoc($get_cinema)) {
		$cinema_name = $row['cinema_name'];
		$row_content = "<option value='".$cinema_name."'>".$cinema_name."</option>";
		$rvCinemaForm .= $row_content;
	}
	$rvCinemaForm .="</select></br><input type='submit' name='rvCinema' value='RemoveCinema'/>
	</form></div>";
	echo $rvCinemaForm;
}



if ($typeAction == "3") {
	$addHallForm = "<div id='add_hall_form'>
	<form id='add-hall' method='post' action='addHall.php'>
	<label for=add_hall_cin'>Choose cinema:</label><select id='add_hall_sel' name='add_hall_cin'>
	<option value='choose_cinema'>Choose cinema</option>";
	$query = "SELECT cinema_name FROM cinema WHERE active_or_not = 0";
	$get_cinema = db_query($query);
	while ($row = mysqli_fetch_assoc($get_cinema)) {
		$cinema_name = $row['cinema_name'];
		$row_content = "<option value='".$cinema_name."'>".$cinema_name."</option>";
		$addHallForm .= $row_content;
	}
	$addHallForm .="</select></br>
				<label class='ahall' for='hall_type'>Choose the shape of the hall: </label></br>
				<select id='hall_type' name='hall_type'>
				<option value='rect'>Rectangular</option>
				<option value='trapz'>Trapezoidal</option>
				</select>
				<br/>
				<label class='ahall' for='num_rows'>Set number of rows: </label><br/>
				<input type='number' id='num_rows' name='num_rows' min='5' max='25' title='Less or equal number than the number of seats on the last row in trapezoidal halls.'/>
				<br/>
				<label class='ahall' for='num_col'>Set number of colums: </label><br/>
				<input type='number' id='num_col' name='num_col' min='5' max='35'/>
				<br/>				
				<label class='ahall' for='num_seats_up'>Number of seats on the last row: </label><br/>
				<input type='number' id='num_seats_up' name='num_seats_up' min='5' max='35' title='Greater or equal number than the number of rows in trapezoidal halls.'/>
				<br/> 
				<input type='submit' name='addHall' value='AddHall'/>
				</form></div>";
	echo $addHallForm;
}

// if($typeAction == "4"){
// 	$rvHallForm = "<div id='rv_hall_form'>
// 	<form id='rv-hall' method='post' action='rvHall.php'>
// 	<label for='rem_hall_cin'>Choose from which cinema: </label><select id='rem_hall_sel_cin' name='rem_hall_cin'>";
// 	$query = "SELECT cinema_name FROM cinema WHERE active_or_not = 0";
// 	$get_cinema = db_query($query);
// 	while ($row = mysqli_fetch_assoc($get_cinema)) {
// 		$cinema_name = $row['cinema_name'];
// 		$row_content = "<option value='".$cinema_name."'>".$cinema_name."</option>";
// 		$rvHallForm .= $row_content;
// 	}
// 	$rvHallForm .="</select></br>
// 	<label for='rem_hall'>Choose hall number: </label><select id='rem_hall' name='rem_hall'></select></br>
// 	<input type='submit' name='rvCinema' value='RemoveCinema'/></form></div>";
// 	echo $rvHallForm;
// }


if($typeAction == "41"){
	$name = db_escape($_POST['cinemaname']);
	$take_cinemaid = "SELECT * FROM cinema WHERE cinema_name = '$name'";
	$get_cinemaid = db_query($take_cinemaid);
	while ($cinemaid = mysqli_fetch_assoc($get_cinemaid)) {
		$cinema_id = $cinemaid['idcinema'];
	}
	$rvHallForm = "";
	$query = "SELECT hall_number FROM halls WHERE cinema_idcinema = '$cinema_id'";
	$get_halls = db_query($query);
	while ($row = mysqli_fetch_assoc($get_halls)) {
		$hall_num = $row['hall_number'];
		$row_content = "<option value='".$hall_num."'>Hall ".$hall_num."</option>";
		$rvHallForm .= $row_content;
	}
	echo $rvHallForm;
}

if($typeAction == "5"){
	$addMoviesForm = "<div id=add_movies_form> <form id='add-movies' method='post' action='addMovies.php'>
				<label class='amovies' for='movie_name'>Movie name: </label>
				<input type='text' id='movie_name' name='movie_name'/>
				<br/>
				<label class='amovies' for='duration'>Duration in minutes: </label>
				<input type='text' id='duration' name='duration'/>
				<br/>
				<label class='amovies' for='picture'>Enter picture path: </label>
				<input type='text' id='picture' name='picture'/>
				<br/>
				<label class='amovies' for='ppf'>Current or upcoming movie: </label></br>
				<select id='ppf' name='ppf'><option value='current'>Current<option/><option value='premiere'>Premiere<option/><option value='upcoming'>Upcoming<option/></select>
				<br/>
				<label class='amovies' for='descr'>Description: </label><br/>
				<input type='text' id='descr' name='descr'/>
				<br/>
				<label class='amovies'>Choose top3 appropriate genres:</label>
				<br/>
				<label class='amovies'>1.</label>
				<select id='genre1'name='genre1'>
					<option value='action'>Action</option>
					<option value='adventure'>Adventure</option>
					<option value='animation'>Animation</option>
					<option value='biography'>Biography</option>
					<option value='comedy'>Comedy</option>
					<option value='crime'>Crime</option>
					<option value='documenraty'>Documentary</option>
					<option value='drama'>Drama</option>
					<option value='family'>Family</option>
					<option value='fantasy'>Fantasy</option>
					<option value='history'>History</option>
					<option value='horror'>Horror</option>
					<option value='musical'>Musical</option>
					<option value='mystery'>Mystery</option>
					<option value='romance'>Romance</option>
					<option value='sci-fi'>Sci-fi</option>
					<option value='thriller'>Thriller</option>
				</select>
				<br/>
				<label class='amovies'>2.</label>
				<select id='genre2'name='genre2'>
					<option value='action'>Action</option>
					<option value='adventure'>Adventure</option>
					<option value='animation'>Animation</option>
					<option value='biography'>Biography</option>
					<option value='comedy'>Comedy</option>
					<option value='crime'>Crime</option>
					<option value='documenraty'>Documentary</option>
					<option value='drama'>Drama</option>
					<option value='family'>Family</option>
					<option value='fantasy'>Fantasy</option>
					<option value='history'>History</option>
					<option value='horror'>Horror</option>
					<option value='musical'>Musical</option>
					<option value='mystery'>Mystery</option>
					<option value='romance'>Romance</option>
					<option value='sci-fi'>Sci-fi</option>
					<option value='thriller'>Thriller</option>
				</select>
				<br/>
				<label class='amovies'>3.</label>
				<select id='genre3'name='genre3'>
					<option value='action'>Action</option>
					<option value='adventure'>Adventure</option>
					<option value='animation'>Animation</option>
					<option value='biography'>Biography</option>
					<option value='comedy'>Comedy</option>
					<option value='crime'>Crime</option>
					<option value='documenraty'>Documentary</option>
					<option value='drama'>Drama</option>
					<option value='family'>Family</option>
					<option value='fantasy'>Fantasy</option>
					<option value='history'>History</option>
					<option value='horror'>Horror</option>
					<option value='musical'>Musical</option>
					<option value='mystery'>Mystery</option>
					<option value='romance'>Romance</option>
					<option value='sci-fi'>Sci-fi</option>
					<option value='thriller'>Thriller</option>
				</select>
				<br/>
				<input type='submit' name='addCinema' value='AddCinema'/>
			</form></div>";
	echo $addMoviesForm;
}

if($typeAction == "6"){
	$chMoviesForm = "<div id='ch_movies_form'>
	<form id='ch-movies' method='post' action='chMovies.php'>
	<label for='ch_mov'>Select Movie to change:</label><select id='ch_movi' name='ch_mov'>";
	$query = "SELECT movie_name FROM movies";
	$get_movie = db_query($query);
	while ($row = mysqli_fetch_assoc($get_movie)) {
		$movie_name = $row['movie_name'];
		$row_content = "<option value='".$movie_name."'>".$movie_name."</option>";
		$chMoviesForm .= $row_content;
	}
	$chMoviesForm .="</select><br/><label for='movie_state'>New State:</label><br/>
	<select id='movie_state' name='movie_state'><option value='past'>Past<option/><option value='current'>Current<option/><option value='premiere'>Premiere<option/><option value='upcoming'>Upcoming<option/></select>
	<input type='submit' name='chMovie' value='Change'/>
	</form></div>";
	echo $chMoviesForm;
}

if($typeAction == "7"){
	$addProjForm = "<div id='add_proj_form'>
	<form id='add-proj' method='post' action='addProj.php'>
	<label for='add_proj_cin'>Choose cinema: </label><select id='add_proj_sel_cin' name='add_proj_cin'>
	<option value='choose_cinema'>Choose cinema</option>";
	$query = "SELECT cinema_name FROM cinema WHERE active_or_not = 0";
	$get_cinema = db_query($query);
	while ($row = mysqli_fetch_assoc($get_cinema)) {
		$cinema_name = $row['cinema_name'];
		$row_content = "<option value='".$cinema_name."'>".$cinema_name."</option>";
		$addProjForm .= $row_content;
	}
	$addProjForm .="</select></br>
	<label for='add_proj_hall'>Choose hall number: </label><select id='add_proj_hall' name='add_proj_hall'></select></br>
	<label for='add_proj_mov'>Choose movie: </label><select id='add_proj_mov' name='add_proj_mov'>";
	$query1 = "SELECT movie_name FROM movies WHERE past_present_future = '1' OR past_present_future = '4'";
	$get_movie = db_query($query1);
	while ($row1 = mysqli_fetch_assoc($get_movie)) {
		$movie_name = $row1['movie_name'];
		$row_content = "<option value='".$movie_name."'>".$movie_name."</option>";
		$addProjForm .= $row_content;
	}

	$addProjForm .="</select></br><label for='add_proj_date'>Choose date: </label><input type='date' name='add_proj_date'></br>
	<label for='add_proj_time'>Choose when the projection begins: </label><input type='time' name='add_proj_time' min='09:00:00' max='23:59:59'></br></br>
	<input type='submit' name='addProj' value='AddProjection'/></form></div>";
	echo $addProjForm;
}

if ($typeAction == "8") {
	$accountDeactForm = "<div id='account_deact_form'>
	<form id='account-deact' method='post' action='accountDeact.php'>
	<label for='user_deact'>Enter username:</label><br>
	<input type='text' name='user_deact'/><br>
	<label>Choose action</label><br>
	<input type='radio' name='actionGroup' value='activate'> Activate <br>
	<input type='radio' name='actionGroup' value='deactivate' checked> Deactivate <br>
	<input type='submit' name='accDeact' value='Action'/>
	</form>
	</div>";
	echo $accountDeactForm;
}

